<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/console/lib/layui-v2.6.3/css/layui.css" media="all">
    <script src="/console/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
</head>

<body>
<ul class="layui-nav" lay-filter="">
    <li class="layui-nav-item"><a href="">最新活动</a></li>
    <li class="layui-nav-item layui-this"><a href="/index">搜索</a></li>
    <li class="layui-nav-item"><a href="/addcontent">内容新建</a></li>
    <li class="layui-nav-item">
        <a href="javascript:;">解决方案</a>
        <dl class="layui-nav-child"> <!-- 二级菜单 -->
            <dd><a href="">移动模块</a></dd>
            <dd><a href="">后台模版</a></dd>
            <dd><a href="">电商平台</a></dd>
        </dl>
    </li>
    <li class="layui-nav-item"><a href="">社区</a></li>
</ul>

<div style="padding: 10px">

        <form class="layui-form" onsubmit="return false;">
            <div class="layui-form-item">
                <label class="layui-form-label">搜索</label>
                <div class="layui-input-block">
                    <#if keyword??>
                    <div style="width: 50%;float: left">
                        <input type="text" name="keyword" value="${keyword}" autocomplete="off" placeholder="请输入关键字" class="layui-input">
                    </div>

                    <#else>
                    <div style="width: 50%;float: left">
                        <input type="text" name="keyword"  autocomplete="off" placeholder="请输入关键字" class="layui-input">
                    </div>
                </#if>
                <div style="float: left;padding-left: 20px">
                    <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
                </div>
            </div>
    </form>
    </div>
</div>





<@titlemodel pageNum=pageNum pageSize=pageSize  keyword=keyword>
    <#if result.data ??>
         <div style="padding-left: 100px;padding-right: 100px">
            <table class="layui-table" style="text-align: center">
                <colgroup>
                    <col width="300">
                    <col width="100">
                    <col width="100">
                    <col width="100">
                    <col width="200">
                    <col>
                </colgroup>
                <thead>
                <tr style="height: 20px">
                    <th style="text-align: center;font-size: 20px;">标题</th>
                    <th style="text-align: center;font-size: 20px">栏目</th>
                    <th style="text-align: center;font-size: 20px">标签</th>
                    <th style="text-align: center;font-size: 20px">作者</th>
                    <th style="text-align: center;font-size: 20px">创建时间</th>
                </tr>
                </thead>
                <tbody>
                    <#list result.data as item>

                        <tr>
                            <#if item.title??>
                                <td><a href="/content?contentId=${item.id}" target="_blank">${item.title}</a></td>
                            </#if>
                            <#if item.channelName??>
                                 <td><a href="/content?contentId=${item.id}" target="_blank">${item.channelName}</a></td>
                            </#if>
                            <#if item.tag??>
                                <td><a href="/content?contentId=${item.id}" target="_blank">${item.tag}</a></td>
                           </#if>
                            <#if item.realname??>
                                <td><a href="/content?contentId=${item.id}" target="_blank">${item.realname}</a></td>
                            </#if>
                            <#if item.createdate??>
                                <td><a href="/content?contentId=${item.id}" target="_blank">${item.createdate}</a></td>
                            </#if>
                        </tr>

                    </#list>
                </tbody>
            </table>
        </div>
    </#if>
<div align="center">
    <div id="test1"></div>
</div>


<script>
    layui.use(['form','laypage','element'], function() {
        var form = layui.form;
        var element = layui.element;
        var laypage = layui.laypage;

        //执行一个laypage实例
        laypage.render({
            elem: 'test1' //注意，这里的 test1 是 ID，不用加 # 号
            ,count: ${result.total} //数据总数，从服务端得到
            ,limit:${result.size}
            ,curr:${result.current}
            ,layout: ['count', 'prev', 'page', 'next', 'refresh', 'skip']
            ,jump: function(obj, first) {
                //obj包含了当前分页的所有参数，比如：
                console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                console.log(obj.limit); //得到每页显示的条数

                //首次不执行
                if (!first) {
                    <#if keyword??>
                        location.href="/index?pageNum="+obj.curr+"&keyword=${keyword}";
                    <#else>
                        location.href="/index?pageNum="+obj.curr;
                    </#if>
                }
            }
        });

        //监听提交
        form.on('submit(demo1)', function (data) {
            location.href="/index?keyword="+data.field.keyword;
        });

    })
</script>


</@titlemodel>




</body>
</html>